package com.kitchen.common.utils;

import org.apache.commons.io.FilenameUtils;
import org.springframework.web.multipart.MultipartFile;


import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class ImageUtils {
    public static String file(MultipartFile file) throws IOException {
        String Filename = file.getOriginalFilename();
        //定制全局唯一的命名
        String unique = UUID.randomUUID().toString();
        //获得文件的后缀
        String extension = FilenameUtils.getExtension(Filename);
        //定制全局唯一的文件名
        String uniqueFileName = unique+"."+extension;
        file.transferTo(new File("D:/kitchen/"+uniqueFileName));
        return uniqueFileName ;
    }
}
